 /*
 * @description: 收入统计-任务收益
 * @Author: along
 * @Date: 2021-06-05
 * @Last Modified by: along
 * @Last Modified time: 2021-06-05
 */
<template>
    <div class="container studentCommissionThrid">

        <!-- header -->
        <div class="header-nav">
            <div class="header-left">
                <div class="header-new-box">
                    <p class="header-new-box-title">收入名称:</p>
                    <el-select
                        v-model="formData.type"
                        filterable
                        placeholder="请选择"
                        size="small"
                        @change="getTableData(1)"
                    >
                        <el-option
                            v-for="item in typeList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                        />
                    </el-select>
                </div>
            </div>
            <div class="header-right">
                <div class="header-new-box">
                    <p class="__info_title">
                        所得任务收益统计：
                        <span>
                            ¥{{ task_total_income ? task_total_income : '0.00' }}
                        </span>
                    </p>
                    <!-- <el-button
                        size="medium"
                        type="primary"
                        :style="{width: '128px', marginLeft: '32px'}"
                        @click="$refs.thridDialog.show('add')"
                    >
                        添加信息
                    </el-button> -->
                </div>
            </div>
        </div>
        <!-- /header -->

        <!-- table -->
        <el-table
            :data="tableData"
            height="100%"
            style="width: 100%;"
            border
            ref="studentCommissionThrid"
        >
            <el-table-column
                type="index"
                width="80"
                label="序号"
                align="center"
            />
            <el-table-column
                prop="task_category"
                label="任务类型"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    {{ scope.row.finance_type | filterType }}
                </template>
            </el-table-column>
            <el-table-column
                prop="task_title"
                label="任务名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            />
            <el-table-column
                prop="task_accept_time"
                label="任务领取时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    {{ scope.row.task_accept_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm:ss') }}
                </template>
            </el-table-column>
            <el-table-column
                prop="award_time"
                label="实际到账时间"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    {{ scope.row.award_time * 1000 | dateFormatter('yyyy/MM/dd HH:mm:ss') }}
                </template>
            </el-table-column>
            <el-table-column
                label="收入名称"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    {{ scope.row.finance_type | financeTypeFilter }}
                </template>
            </el-table-column>
            <el-table-column
                prop="award_money"
                label="任务奖励"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    ¥{{ scope.row.award_money ? scope.row.award_money : '0.00' }}
                </template>
            </el-table-column>
            <el-table-column
                prop="award_money_act"
                label="实际获得金额"
                show-overflow-tooltip
                :formatter="emptyFormatter"
                align="left"
            >
                <template slot-scope="scope">
                    ¥{{ scope.row.award_money_act ? scope.row.award_money_act : '0.00' }}
                </template>
            </el-table-column>
            <!-- <el-table-column
                label="操作"
                align="center"
            >
                <template slot-scope="scope">
                    <el-button
                        type="text"
                        class="curse-add"
                        @click="handleEditData(scope.row)"
                    >
                        修改
                    </el-button>
                    <el-button
                        type="text"
                        class="curse-add"
                        :style="{color: 'rgba(249, 91, 86, 1)'}"
                        @click="handleDeleteData(scope.row)"
                    >
                        删除
                    </el-button>
                </template>
            </el-table-column> -->
        </el-table>
        <!-- /table -->

        <!-- /分页 -->
        <div class="pagination-wrapper clearfix">
            <el-pagination
                background
                layout="total, prev, pager, next"
                :current-page.sync="page.now_page"
                :total="page.total_count"
                :page-size="page.page_size"
                @current-change="getTableData"
            />
        </div>

        <!-- 添加编辑信息 -->
        <!-- <thrid-dialog
            ref="thridDialog"
            @emit="handleGetList"
        /> -->
    </div>
</template>

<script>
// import thridDialog from '@/components/student/student-thrid-dialog.vue';
import { back } from '@/mixin/back';
export default {
    mixins: [back],
    components: {
        // thridDialog
    },
    props: {
        agent_no: {
            type: String,
            default: ''
        },
        task_total_income: {
            type: Number,
            default: 0
        },
        start_time: {
            type: Number,
            default: 0
        },
        end_time: {
            type: Number,
            default: 0
        }
    },
    data () {
        return {
            formData: {
                type: 99
            },
            page: {
                now_page: 1,
                total_count: 0,
                page_size: 0
            },
            typeList: [
                // 99全部,1:任务收益,11:一级粉丝任务收益12:二级粉丝任务收益,2:邀请奖励,21:一级粉丝邀请奖励,22:二级粉丝邀请奖励
                {value: 99,label: '全部'},
                {value: 1,label: '任务收益'},
                {value: 11,label: '一级粉丝任务收益'},
                {value: 12,label: '二级粉丝任务收益'},
                {value: 2,label: '邀请奖励'},
                {value: 21,label: '一级粉丝邀请奖励'},
                {value: 22,label: '二级粉丝邀请奖励'},
                {value: 3,label: '创建同校班级奖励'},
                {value: 31,label: '一级粉丝创建同校班级奖励'},
                {value: 32,label: '二级粉丝创建同校班级奖励'}
            ],
            tableData: [],
            authResult: {}
        };
    },
    filters: {
        filterType (val) {
            switch (val) {
                case 203:
                case 205:
                case 206:
                    return '精英任务';
                case 204:
                case 207:
                case 208:
                    return '远程任务';
                case 209:
                case 210:
                case 211:
                    return '邀请好友';
                case 212:
                case 213:
                case 214:
                    return '创建班级';
                default:
                    return '--';
            }
        },
        financeTypeFilter(val) {
            // 一级粉丝任务收益，二级粉丝任务收益，邀请奖励，一级粉丝邀请奖励，二级粉丝邀请奖励，创建同校班级奖励，一级粉丝创建同校班级奖励，二级粉丝创建同校班级奖励。
            // 明细类型，自身收益:精英任务203,商家任务204,邀请粉丝209，一级收益：精英任务205,商家任务207,邀请粉丝210，二级收益：精英任务206, 商家任务208, 邀请有礼211,
            // 212:创建同校班级奖励,213一级粉丝创建班级奖励,214二级粉丝创建班级奖励
            switch (val) {
                case 203:
                case 204:
                    return '任务收益';
                case 205:
                case 207:
                    return '一级粉丝任务收益';
                case 206:
                case 208:
                    return '二级粉丝任务收益';
                case 209:
                    return '邀请奖励';
                case 210:
                    return '一级粉丝邀请奖励';
                case 211:
                    return '二级粉丝邀请奖励';
                case 212:
                    return '创建同校班级奖励';
                case 213:
                    return '一级粉丝创建班级奖励';
                case 214:
                    return '二级粉丝创建班级奖励';
                default:
                    return '--';
            }
        },
    },
    computed: {},
    watch: {
        start_time (val) {
            this.getTableData();
        },
        end_time (val) {
            this.getTableData();
        }
    },
    mounted () {
        this.authResult = this.$route.meta.authResult;
        this.getTableData();
    },
    methods: {
        /**
         * @description 获取表格数据
         */
        getTableData (page) {
            this.$post('/student/stuagent_rebate%5Cget_task_total_income_list', {
                page_id: page || this.page.now_page,
                type: this.formData.type,
                agent_no: this.agent_no,
                start_time: this.start_time,
                end_time: this.end_time
            }, resp => {
                if (resp.code == 1) {
                    this.tableData = resp.data.list;
                    this.page.now_page = resp.data.page.now_page;
                    this.page.total_count = resp.data.page.total_count;
                    this.page.page_size = resp.data.page.page_size;
                }
            });
        },

        /**
         * @description 编辑信息
         */
        // handleEditData (row) {
        //     this.$refs.thridDialog.show('edit', [{
        //         task_type: '1',//任务类型
        //         task_title: '2',//任务名称
        //         task_award_money: '3',//任务奖励
        //         task_actual_money: '4',//实际获得金额
        //         task_time: 1619411400000,//任务领取时间
        //         task_award_time: 1619411400000//奖金到账时间
        //     }]);
        // },

        /**
         * @description 删除
         */
        // handleDeleteData (row) {
        //     this.$confirm('是否要删除当前数据?', '提示', {
        //         confirmButtonText: '确定',
        //         cancelButtonText: '取消',
        //         type: 'warning'
        //     }).then(() => {
        //         this.$post('', {
        //             //
        //         }, resp => {
        //             if (resp.code === 1) {
        //                 this.getTableData();
        //                 this.$notify({
        //                     title: '提示',
        //                     message: '操作成功',
        //                     type: 'success',
        //                     duration: 2000
        //                 });
        //             } else {
        //                 this.$notify({
        //                     title: '失败',
        //                     message: resp.msg,
        //                     duration: 2000,
        //                     type: 'warning'
        //                 });
        //             }
        //         });
        //     });
        // },

        /**
         * @description 确认添加信息
         */
        // handleGetList (row) {

        //     const url = row.type == 'add' ? '' : '';

        //     console.log('---row---', row);

        //     this.$post(url, {
        //         //
        //     }, resp => {
        //         if (resp.code === 1) {
        //             this.getTableData();
        //             this.$notify({
        //                 title: '提示',
        //                 message: '操作成功',
        //                 type: 'success',
        //                 duration: 2000
        //             });
        //         } else {
        //             this.$notify({
        //                 title: '失败',
        //                 message: resp.msg,
        //                 duration: 2000,
        //                 type: 'warning'
        //             });
        //         }
        //     });
        // },

        /**
         * @description 过滤函数
         */
        emptyFormatter(row, column, val) {
            if (!val) return '--';
            return val;
        }
    }
};
</script>

<style lang="less" scoped>
    .container {
        background-color: #fff;
        padding: 24px 32px 12px 32px;
        display: flex;
        flex-direction: column;
        position: relative;
        width: 100%;
        .header-nav {
            position: relative;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
            .header-left, .header-right {
                display: flex;
                align-items: center;
                flex-wrap: wrap;
            }
            .header-new-box {
                display: flex;
                margin-right: 15px;
                align-items: center;
                color: #606266;
                margin-bottom: 24px;
                white-space: nowrap;
                &-title {
                    margin-right: 12px;
                    white-space: nowrap;
                }
                .__info_title {
                    display: flex;
                    align-items: center;
                    color: rgba(51, 51, 51, 1);
                    font-size: 14px;
                    span {
                        color: rgba(255, 142, 57, 1);
                        font-weight: 500;
                        font-size: 14px;
                    }
                }
            }
        }
        /* 表单 */
        .scope-price {
            width: 50px;
            height: 50px;
        }
        /* 字体高亮 */
        .cursor-font {
            color: rgb(64, 158, 255);
            cursor: pointer;
        }
        /* 分页 */
        .pagination-wrapper {
            padding-top: 10px;
            padding-bottom: 10px;
            .el-pagination {
                float: right;
                padding: 0;
                background-color: transparent;
            }
        }
    }
    /* 排序 */
    .sort-wrap {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        .sort-spliter {
            width: 1px;
            height: 12px;
            background: rgba(235, 235, 235, 1);
            margin: 0 10px;
            }
            .btn-sort {
            font-size: 14px;
            line-height: 1;
            color: #ccc;
            &:hover {
                color: #20a0ff;
            }
        }
    }

    .__zsdx_wrap {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        .__top {
            display: flex;
            align-items: center;
            .__top_name {
                color: rgba(51, 51, 51, 1);
                font-size: 14px;
                font-weight: 500;
                margin-right: 6px;
            }
            .__top_logo {
                width: 28px;
                height: 14px;
            }
        }
        .__phone {
            height: 20px;
            color: rgba(153, 153, 153, 1);
            font-size: 14px;
            line-height: 20px;
            margin-top: 7px;
            margin-bottom: 5px;
        }
        .__id {
            height: 20px;
            color: rgba(153, 153, 153, 1);
            font-size: 14px;
            line-height: 20px;
        }
    }

    .el-button-left {
        margin-left: 40px;
    }
    .el-button-right {
        margin-right: 10px;
    }
</style>
<style lang="less">
    .studentCommissionThrid{
        .el-table__body-wrapper .el-table__body .el-table__row td {
            border-right: none;
        }
        .el-table__header-wrapper .el-table__header .has-gutter tr th {
            border-right: none;
        }
        .el-table .el-table_1_column_6  .cell {
            position: relative;
        }
        .el-range-editor--small .el-range-separator{
            padding: 0 1px !important;
        }
    }
</style>
